<section id="my-queries" class="container padding-zero-left">
    <div class="col-lg-12 column12 mopo">
        <div class="table">
            <div class="table-head row">
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">Serial no.</div>
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">Name</div>
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">workshop/course</div>
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">Query date</div>
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">Time since query</div>
                <div class="col-lg-2 col-md-2 col-sm-2 mopo">Response</div>
            </div>
            <?php
            $this->widget('zii.widgets.CListView', array(
                'dataProvider' => $dataProvider,
                'itemView' => '_view',
                'id' => 'ajaxListView',
                'summaryText' => '',
            ));
            ?>


        </div>
    </div>   
</section>


<script>
    function showQuery(id) {
        $(".sendMessageTouserOpenBox").hide();
        $("#open_msg_box_" + id).toggle('slow').show();
    }
    function hideQuery(id) {
        $(".sendMessageTouserOpenBox").hide();
        $("#open_msg_box_" + id).toggle('slow').hide();
    }
    function convertUser(id) {
        if ($("#convert_" + id).is(':checked'))
            $("#convert_user_" + id).val(1);  // checked
        else
            $("#convert_user_" + id).val('');  // checked
    }
    function replytousers(id, classid, userid, classcoursetyp) {
        var convertuser = $("#convert_user_" + id).val('');
        if (convertuser != '') {
            updateConvert(id, 1);
        }
        var subject = $("#subject_" + id).val();
        var msgval = $("#message_text_" + id).val();
        if (msgval == '') {
            $("#errorMessage_subject_" + id).text('');
            $("#errorMessage_msg_" + id).text('Message  can not blank.')
            return false;
        }
        if (msgval != '') {
            jQuery.ajax({
                'type': 'POST',
                'url': "<?php echo Yii::app()->createAbsoluteUrl("MailConversation/sendMailTouser"); ?>",
                'data': 'YII_CSRF_TOKEN=' + $('input[name="YII_CSRF_TOKEN"]').val() + "&selectedUser=" + userid + "&subject=" + subject + "&msgval=" + msgval + "&classId=" + classid + "&makeQueryId=" + id + "&type=" + classcoursetyp,
                'beforeSend': function(jqXHR, settings) {
                    $("#queryLoder_" + id).show();
                },
                'success': function(data) {
                    $("#queryLoder_" + id).hide();
                    if ($.trim(data) == 'success') {
                        $("#open_msg_box_" + id).toggle('slow').hide();
                        $("#form_result_" + id).show();
                        $(".formResult_" + id).html("Mail Send Successfully .");
                    }
                },
                'cache': false
            });
        }

    }


    function updateConvert(queryId) {
        var checked=1;
        if($("#convert_"+queryId).is(':checked')){    
            jQuery.ajax({
                'type': 'POST',
                'url': "<?php echo Yii::app()->createAbsoluteUrl("MakeQuery/UpdateConvert"); ?>",
                data: 'YII_CSRF_TOKEN=' + $('input[name="YII_CSRF_TOKEN"]').val() + "&MakeQuery[id]=" + queryId + '&checked=' + checked,
                'success': function(data) {
                },
                'cache': false});
        }}
</script>
